package cn.lzd.mvp.base.net;

/**
 * 网络请求返回基类
 * @param <T> 返回数据中 data 的数据类型
 */
public class CommonResBean<T> {
    private int code;
    private String msg;
    private int msgId;
    private int time;
    private T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public int getMsgId() {
        return msgId;
    }

    public void setMsgId(int msgId) {
        this.msgId = msgId;
    }

    public int getTime() {
        return time;
    }

    public void setTime(int time) {
        this.time = time;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String checkCode() {
        NetCode netCode = NetCode.checkCode(code);
        if (netCode == null) {
            return null;
        }
        if (netCode == NetCode.CustomError) {
            return msg;
        } else {
            return netCode.message;
        }
    }
}